home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / a2.0bemacs-src.lha / Emacs-19.25 / src / frame.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-30  |  61.2 KB  |  2,232 lines

  1. /* Generic frame functions.
  2.    Copyright (C) 1993, 1994 Free Software Foundation.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <stdio.h>
  21.  
  22. #include <config.h>
  23. #include "lisp.h"
  24. #include "frame.h"
  25. #include "termhooks.h"
  26. #include "window.h"
  27.  
  28. /* CHFIXME: cleanup HAVE_MOUSE changes, add staticpro, cleanup AMIGA changes (undo/change MULTI_FRAME changes) */
  29. #ifdef AMIGA /* CHFIXME */
  30. #include "amiga.h"
  31. #endif
  32.  
  33. #ifdef MULTI_FRAME
  34.  
  35. #include "buffer.h"
  36.  
  37. /* These help us bind and responding to switch-frame events.  */
  38. #include "commands.h"
  39. #include "keyboard.h"
  40.  
  41. Lisp_Object Vemacs_iconified;
  42. Lisp_Object Vframe_list;
  43. Lisp_Object Vterminal_frame;
  44. Lisp_Object Vdefault_minibuffer_frame;
  45. Lisp_Object Vdefault_frame_alist;
  46.  
  47. /* Evaluate this expression to rebuild the section of syms_of_frame
  48.    that initializes and staticpros the symbols declared below.  Note
  49.    that Emacs 18 has a bug that keeps C-x C-e from being able to
  50.    evaluate this expression.
  51.  
  52. (progn
  53.   ;; Accumulate a list of the symbols we want to initialize from the
  54.   ;; declarations at the top of the file.
  55.   (goto-char (point-min))
  56.   (search-forward "/\*&&& symbols declared here &&&*\/\n")
  57.   (let (symbol-list)
  58.     (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
  59.       (setq symbol-list
  60.         (cons (buffer-substring (match-beginning 1) (match-end 1))
  61.           symbol-list))
  62.       (forward-line 1))
  63.     (setq symbol-list (nreverse symbol-list))
  64.     ;; Delete the section of syms_of_... where we initialize the symbols.
  65.     (search-forward "\n  /\*&&& init symbols here &&&*\/\n")
  66.     (let ((start (point)))
  67.       (while (looking-at "^  Q")
  68.     (forward-line 2))
  69.       (kill-region start (point)))
  70.     ;; Write a new symbol initialization section.
  71.     (while symbol-list
  72.       (insert (format "  %s = intern (\"" (car symbol-list)))
  73.       (let ((start (point)))
  74.     (insert (substring (car symbol-list) 1))
  75.     (subst-char-in-region start (point) ?_ ?-))
  76.       (insert (format "\");\n  staticpro (&%s);\n" (car symbol-list)))
  77.       (setq symbol-list (cdr symbol-list)))))
  78.   */        
  79.  
  80. /*&&& symbols declared here &&&*/
  81. Lisp_Object Qframep;
  82. Lisp_Object Qframe_live_p;
  83. Lisp_Object Qheight;
  84. Lisp_Object Qicon;
  85. Lisp_Object Qminibuffer;
  86. Lisp_Object Qmodeline;
  87. Lisp_Object Qname;
  88. Lisp_Object Qonly;
  89. Lisp_Object Qunsplittable;
  90. Lisp_Object Qmenu_bar_lines;
  91. Lisp_Object Qwidth;
  92. Lisp_Object Qx;
  93. Lisp_Object Qvisible;
  94.  
  95. extern Lisp_Object Vminibuffer_list;
  96. extern Lisp_Object get_minibuffer ();
  97. extern Lisp_Object Fhandle_switch_frame ();
  98. extern Lisp_Object Fredirect_frame_focus ();
  99.  
  100. DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
  101.   "Return non-nil if OBJECT is a frame.\n\
  102. Value is t for a termcap frame (a character-only terminal),\n\
  103. `x' for an Emacs frame that is really an X window.\n\
  104. Also see `live-frame-p'.")
  105.   (object)
  106.      Lisp_Object object;
  107. {
  108.   if (XTYPE (object) != Lisp_Frame)
  109.     return Qnil;
  110.   switch (XFRAME (object)->output_method)
  111.     {
  112.     case output_termcap:
  113.       return Qt;
  114.     case output_x_window:
  115.       return Qx;
  116.     default:
  117.       abort ();
  118.     }
  119. }
  120.  
  121. DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
  122.   "Return non-nil if OBJECT is a frame which has not been deleted.\n\
  123. Value is nil if OBJECT is not a live frame.  If object is a live\n\
  124. frame, the return value indicates what sort of output device it is\n\
  125. displayed on.  Value is t for a termcap frame (a character-only\n\
  126. terminal), `x' for an Emacs frame being displayed in an X window.")
  127.   (object)
  128.      Lisp_Object object;
  129. {
  130.   return ((FRAMEP (object)
  131.        && FRAME_LIVE_P (XFRAME (object)))
  132.       ? Fframep (object)
  133.       : Qnil);
  134. }
  135.  
  136. struct frame *
  137. make_frame (mini_p)
  138.      int mini_p;
  139. {
  140.   Lisp_Object frame;
  141.   register struct frame *f;
  142.   register Lisp_Object root_window;
  143.   register Lisp_Object mini_window;
  144.  
  145.   frame = Fmake_vector (((sizeof (struct frame) - (sizeof (Lisp_Vector)
  146.                              - sizeof (Lisp_Object)))
  147.               / sizeof (Lisp_Object)),
  148.              make_number (0));
  149.   XSETTYPE (frame, Lisp_Frame);
  150.   f = XFRAME (frame);
  151.  
  152.   f->cursor_x = 0;
  153.   f->cursor_y = 0;
  154.   f->current_glyphs = 0;
  155.   f->desired_glyphs = 0;
  156.   f->visible = 0;
  157.   f->async_visible = 0;
  158.   f->display.nothing = 0;
  159.   f->iconified = 0;
  160.   f->async_iconified = 0;
  161.   f->wants_modeline = 1;
  162.   f->auto_raise = 0;
  163.   f->auto_lower = 0;
  164.   f->no_split = 0;
  165.   f->garbaged = 0;
  166.   f->has_minibuffer = mini_p;
  167.   f->focus_frame = Qnil;
  168.   f->explicit_name = 0;
  169.   f->can_have_scroll_bars = 0;
  170.   f->has_vertical_scroll_bars = 0;
  171.   f->param_alist = Qnil;
  172.   f->scroll_bars = Qnil;
  173.   f->condemned_scroll_bars = Qnil;
  174.   f->face_alist = Qnil;
  175.   f->menu_bar_items = Qnil;
  176.   f->menu_bar_vector = Qnil;
  177.   f->menu_bar_items_used = 0;
  178.  
  179.   root_window = make_window ();
  180.   if (mini_p)
  181.     {
  182.       mini_window = make_window ();
  183.       XWINDOW (root_window)->next = mini_window;
  184.       XWINDOW (mini_window)->prev = root_window;
  185.       XWINDOW (mini_window)->mini_p = Qt;
  186.       XWINDOW (mini_window)->frame = frame;
  187.       f->minibuffer_window = mini_window;
  188.     }
  189.   else
  190.     {
  191.       mini_window = Qnil;
  192.       XWINDOW (root_window)->next = Qnil;
  193.       f->minibuffer_window = Qnil;
  194.     }
  195.  
  196.   XWINDOW (root_window)->frame = frame;
  197.  
  198.   /* 10 is arbitrary,
  199.      just so that there is "something there."
  200.      Correct size will be set up later with change_frame_size.  */
  201.  
  202.   f->width = 10;
  203.   f->height = 10;
  204.  
  205.   XFASTINT (XWINDOW (root_window)->width) = 10;
  206.   XFASTINT (XWINDOW (root_window)->height) = (mini_p ? 9 : 10);
  207.  
  208.   if (mini_p)
  209.     {
  210.       XFASTINT (XWINDOW (mini_window)->width) = 10;
  211.       XFASTINT (XWINDOW (mini_window)->top) = 9;
  212.       XFASTINT (XWINDOW (mini_window)->height) = 1;
  213.     }
  214.  
  215.   /* Choose a buffer for the frame's root window.  */
  216.   {
  217.     Lisp_Object buf;
  218.  
  219.     XWINDOW (root_window)->buffer = Qt;
  220.     buf = Fcurrent_buffer ();
  221.     /* If buf is a 'hidden' buffer (i.e. one whose name starts with
  222.        a space), try to find another one.  */
  223.     if (XSTRING (Fbuffer_name (buf))->data[0] == ' ')
  224.       buf = Fother_buffer (buf, Qnil);
  225.     Fset_window_buffer (root_window, buf);
  226.   }
  227.  
  228.   if (mini_p)
  229.     {
  230.       XWINDOW (mini_window)->buffer = Qt;
  231.       Fset_window_buffer (mini_window,
  232.               (NILP (Vminibuffer_list)
  233.                ? get_minibuffer (0)
  234.                : Fcar (Vminibuffer_list)));
  235.     }
  236.  
  237.   f->root_window = root_window;
  238.   f->selected_window = root_window;
  239.   /* Make sure this window seems more recently used than
  240.      a newly-created, never-selected window.  */
  241.   XFASTINT (XWINDOW (f->selected_window)->use_time) = ++window_select_count;
  242.  
  243.   return f;
  244. }
  245.  
  246. /* Make a frame using a separate minibuffer window on another frame.
  247.    MINI_WINDOW is the minibuffer window to use.  nil means use the
  248.    default (the global minibuffer).  */
  249.  
  250. struct frame *
  251. make_frame_without_minibuffer (mini_window)
  252.      register Lisp_Object mini_window;
  253. {
  254.   register struct frame *f;
  255.  
  256.   /* Choose the minibuffer window to use.  */
  257.   if (NILP (mini_window))
  258.     {
  259.       if (XTYPE (Vdefault_minibuffer_frame) != Lisp_Frame)
  260.     error ("default-minibuffer-frame must be set when creating minibufferless frames");
  261.       if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame)))
  262.     error ("default-minibuffer-frame must be a live frame");
  263.       mini_window = XFRAME (Vdefault_minibuffer_frame)->minibuffer_window;
  264.     }
  265.   else
  266.     {
  267.       CHECK_LIVE_WINDOW (mini_window, 0);
  268.     }
  269.  
  270.   /* Make a frame containing just a root window.  */
  271.   f = make_frame (0);
  272.  
  273.   /* Install the chosen minibuffer window, with proper buffer.  */
  274.   f->minibuffer_window = mini_window;
  275.   Fset_window_buffer (mini_window,
  276.               (NILP (Vminibuffer_list)
  277.                ? get_minibuffer (0)
  278.                : Fcar (Vminibuffer_list)));
  279.   return f;
  280. }
  281.  
  282. /* Make a frame containing only a minibuffer window.  */
  283.  
  284. struct frame *
  285. make_minibuffer_frame ()
  286. {
  287.   /* First make a frame containing just a root window, no minibuffer.  */
  288.  
  289.   register struct frame *f = make_frame (0);
  290.   register Lisp_Object mini_window;
  291.   register Lisp_Object frame;
  292.  
  293.   XSET (frame, Lisp_Frame, f);
  294.  
  295.   f->auto_raise = 0;
  296.   f->auto_lower = 0;
  297.   f->no_split = 1;
  298.   f->wants_modeline = 0;
  299.   f->has_minibuffer = 1;
  300.  
  301.   /* Now label the root window as also being the minibuffer.
  302.      Avoid infinite looping on the window chain by marking next pointer
  303.      as nil. */
  304.  
  305.   mini_window = f->minibuffer_window = f->root_window;
  306.   XWINDOW (mini_window)->mini_p = Qt;
  307.   XWINDOW (mini_window)->next = Qnil;
  308.   XWINDOW (mini_window)->prev = Qnil;
  309.   XWINDOW (mini_window)->frame = frame;
  310.  
  311.   /* Put the proper buffer in that window.  */
  312.  
  313.   Fset_window_buffer (mini_window,
  314.               (NILP (Vminibuffer_list)
  315.                ? get_minibuffer (0)
  316.                : Fcar (Vminibuffer_list)));
  317.   return f;
  318. }
  319.  
  320. /* Construct a frame that refers to the terminal (stdin and stdout).  */
  321.  
  322. struct frame *
  323. make_terminal_frame ()
  324. {
  325.   register struct frame *f;
  326.   Lisp_Object frame;
  327.  
  328.   Vframe_list = Qnil;
  329.   f = make_frame (1);
  330.  
  331.   XSET (frame, Lisp_Frame, f);
  332.   Vframe_list = Fcons (frame, Vframe_list);
  333.  
  334.   f->name = build_string ("terminal");
  335.   FRAME_SET_VISIBLE (f, 1);
  336.   f->display.nothing = 1;   /* Nonzero means frame isn't deleted.  */
  337.   XSET (Vterminal_frame, Lisp_Frame, f);
  338.   return f;
  339. }
  340.  
  341. static Lisp_Object
  342. do_switch_frame (frame, no_enter, track)
  343.      Lisp_Object frame, no_enter;
  344.      int track;
  345. {
  346.   /* If FRAME is a switch-frame event, extract the frame we should
  347.      switch to.  */
  348.   if (CONSP (frame)
  349.       && EQ (XCONS (frame)->car, Qswitch_frame)
  350.       && CONSP (XCONS (frame)->cdr))
  351.     frame = XCONS (XCONS (frame)->cdr)->car;
  352.  
  353.   /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
  354.      a switch-frame event to arrive after a frame is no longer live,
  355.      especially when deleting the initial frame during startup.  */
  356.   CHECK_FRAME (frame, 0);
  357.   if (! FRAME_LIVE_P (XFRAME (frame)))
  358.     return Qnil;
  359.  
  360.   if (selected_frame == XFRAME (frame))
  361.     return frame;
  362.  
  363.   /* This is too greedy; it causes inappropriate focus redirection
  364.      that's hard to get rid of.  */
  365. #if 0
  366.   /* If a frame's focus has been redirected toward the currently
  367.      selected frame, we should change the redirection to point to the
  368.      newly selected frame.  This means that if the focus is redirected
  369.      from a minibufferless frame to a surrogate minibuffer frame, we
  370.      can use `other-window' to switch between all the frames using
  371.      that minibuffer frame, and the focus redirection will follow us
  372.      around.  */
  373.   if (track)
  374.     {
  375.       Lisp_Object tail;
  376.  
  377.       for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
  378.     {
  379.       Lisp_Object focus;
  380.  
  381.       if (XTYPE (XCONS (tail)->car) != Lisp_Frame)
  382.         abort ();
  383.  
  384.       focus = FRAME_FOCUS_FRAME (XFRAME (XCONS (tail)->car));
  385.  
  386.       if (XTYPE (focus) == Lisp_Frame
  387.           && XFRAME (focus) == selected_frame)
  388.         Fredirect_frame_focus (XCONS (tail)->car, frame);
  389.     }
  390.     }
  391. #else /* ! 0 */
  392.   /* Instead, apply it only to the frame we're pointing to.  */
  393. #ifdef HAVE_X_WINDOWS
  394.   if (track)
  395.     {
  396.       Lisp_Object focus, xfocus;
  397.  
  398.       xfocus = x_get_focus_frame ();
  399.       if (FRAMEP (xfocus))
  400.     {
  401.       focus = FRAME_FOCUS_FRAME (XFRAME (xfocus));
  402.       if (FRAMEP (focus) && XFRAME (focus) == selected_frame)
  403.         Fredirect_frame_focus (xfocus, frame);
  404.     }
  405.     }
  406. #endif /* HAVE_X_WINDOWS */
  407. #endif /* ! 0 */
  408.  
  409.   selected_frame = XFRAME (frame);
  410.   if (! FRAME_MINIBUF_ONLY_P (selected_frame))
  411.     last_nonminibuf_frame = selected_frame;
  412.  
  413.   Fselect_window (XFRAME (frame)->selected_window);
  414.   choose_minibuf_frame ();
  415.  
  416.   /* We want to make sure that the next event generates a frame-switch
  417.      event to the appropriate frame.  This seems kludgy to me, but
  418.      before you take it out, make sure that evaluating something like
  419.      (select-window (frame-root-window (new-frame))) doesn't end up
  420.      with your typing being interpreted in the new frame instead of
  421.      the one you're actually typing in.  */
  422.   internal_last_event_frame = Qnil;
  423.  
  424.   return frame;
  425. }
  426.  
  427. DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
  428.   "Select the frame FRAME.\n\
  429. Subsequent editing commands apply to its selected window.\n\
  430. The selection of FRAME lasts until the next time the user does\n\
  431. something to select a different frame, or until the next time this\n\
  432. function is called.")
  433.   (frame, no_enter)
  434.     Lisp_Object frame, no_enter;
  435. {
  436.   return do_switch_frame (frame, no_enter, 1);
  437. }
  438.  
  439.  
  440. DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e",
  441.   "Handle a switch-frame event EVENT.\n\
  442. Switch-frame events are usually bound to this function.\n\
  443. A switch-frame event tells Emacs that the window manager has requested\n\
  444. that the user's events be directed to the frame mentioned in the event.\n\
  445. This function selects the selected window of the frame of EVENT.\n\
  446. \n\
  447. If EVENT is frame object, handle it as if it were a switch-frame event\n\
  448. to that frame.")
  449.   (frame, no_enter)
  450.      Lisp_Object frame, no_enter;
  451. {
  452.   return do_switch_frame (frame, no_enter, 0);
  453. }
  454.  
  455.  
  456. DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
  457.   "Return the frame that is now selected.")
  458.   ()
  459. {
  460.   Lisp_Object tem;
  461.   XSET (tem, Lisp_Frame, selected_frame);
  462.   return tem;
  463. }
  464.  
  465. DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
  466.   "Return the frame object that window WINDOW is on.")
  467.   (window)
  468.      Lisp_Object window;
  469. {
  470.   CHECK_LIVE_WINDOW (window, 0);
  471.   return XWINDOW (window)->frame;
  472. }
  473.  
  474. DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
  475.   "Returns the topmost, leftmost window of FRAME.\n\
  476. If omitted, FRAME defaults to the currently selected frame.")
  477.   (frame)
  478.      Lisp_Object frame;
  479. {
  480.   Lisp_Object w;
  481.  
  482.   if (NILP (frame))
  483.     w = selected_frame->root_window;
  484.   else
  485.     {
  486.       CHECK_LIVE_FRAME (frame, 0);
  487.       w = XFRAME (frame)->root_window;
  488.     }
  489.   while (NILP (XWINDOW (w)->buffer))
  490.     {
  491.       if (! NILP (XWINDOW (w)->hchild))
  492.     w = XWINDOW (w)->hchild;
  493.       else if (! NILP (XWINDOW (w)->vchild))
  494.     w = XWINDOW (w)->vchild;
  495.       else
  496.     abort ();
  497.     }
  498.   return w;
  499. }
  500.  
  501. DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
  502.        "Returns the root-window of FRAME.\n\
  503. If omitted, FRAME defaults to the currently selected frame.")
  504.   (frame)
  505.      Lisp_Object frame;
  506. {
  507.   if (NILP (frame))
  508.     XSET (frame, Lisp_Frame, selected_frame);
  509.   else
  510.     CHECK_LIVE_FRAME (frame, 0);
  511.  
  512.   return XFRAME (frame)->root_window;
  513. }
  514.  
  515. DEFUN ("frame-selected-window", Fframe_selected_window,
  516.        Sframe_selected_window, 0, 1, 0,
  517.   "Return the selected window of frame object FRAME.\n\
  518. If omitted, FRAME defaults to the currently selected frame.")
  519.   (frame)
  520.      Lisp_Object frame;
  521. {
  522.   if (NILP (frame))
  523.     XSET (frame, Lisp_Frame, selected_frame);
  524.   else
  525.     CHECK_LIVE_FRAME (frame, 0);
  526.  
  527.   return XFRAME (frame)->selected_window;
  528. }
  529.  
  530. DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
  531.        Sset_frame_selected_window, 2, 2, 0,
  532.   "Set the selected window of frame object FRAME to WINDOW.\n\
  533. If FRAME is nil, the selected frame is used.\n\
  534. If FRAME is the selected frame, this makes WINDOW the selected window.")
  535.   (frame, window)
  536.      Lisp_Object frame, window;
  537. {
  538.   if (NILP (frame))
  539.     XSET (frame, Lisp_Frame, selected_frame);
  540.   else
  541.     CHECK_LIVE_FRAME (frame, 0);
  542.  
  543.   CHECK_LIVE_WINDOW (window, 1);
  544.  
  545.   if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
  546.     error ("In `set-frame-selected-window', WINDOW is not on FRAME");
  547.  
  548.   if (XFRAME (frame) == selected_frame)
  549.     return Fselect_window (window);
  550.  
  551.   return XFRAME (frame)->selected_window = window;
  552. }
  553.  
  554. DEFUN ("frame-list", Fframe_list, Sframe_list,
  555.        0, 0, 0,
  556.        "Return a list of all frames.")
  557.   ()
  558. {
  559.   return Fcopy_sequence (Vframe_list);
  560. }
  561.  
  562. /* Return the next frame in the frame list after FRAME.
  563.    If MINIBUF is nil, exclude minibuffer-only frames.
  564.    If MINIBUF is a window, include only frames using that window for
  565.    their minibuffer.
  566.    If MINIBUF is `visible', include all visible frames.
  567.    Otherwise, include all frames.  */
  568.  
  569. Lisp_Object
  570. next_frame (frame, minibuf)
  571.      Lisp_Object frame;
  572.      Lisp_Object minibuf;
  573. {
  574.   Lisp_Object tail;
  575.   int passed = 0;
  576.  
  577.   /* There must always be at least one frame in Vframe_list.  */
  578.   if (! CONSP (Vframe_list))
  579.     abort ();
  580.  
  581.   /* If this frame is dead, it won't be in Vframe_list, and we'll loop
  582.      forever.  Forestall that.  */
  583.   CHECK_LIVE_FRAME (frame, 0);
  584.  
  585.   while (1)
  586.     for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
  587.       {
  588.     Lisp_Object f;
  589.  
  590.     f = XCONS (tail)->car;
  591.     if (passed)
  592.       {
  593.         /* Decide whether this frame is eligible to be returned.  */
  594.  
  595.         /* If we've looped all the way around without finding any
  596.            eligible frames, return the original frame.  */
  597.         if (EQ (f, frame))
  598.           return f;
  599.  
  600.         /* Let minibuf decide if this frame is acceptable.  */
  601.         if (NILP (minibuf))
  602.           {
  603.         if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
  604.           return f;
  605.           }
  606.         else if (EQ (minibuf, Qvisible))
  607.           {
  608.         FRAME_SAMPLE_VISIBILITY (XFRAME (f));
  609.         if (FRAME_VISIBLE_P (XFRAME (f)))
  610.           return f;
  611.           }
  612.         else if (WINDOWP (minibuf))
  613.           {
  614.         if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf))
  615.           return f;
  616.           }
  617.         else
  618.           return f;
  619.       }
  620.  
  621.     if (EQ (frame, f))
  622.       passed++;
  623.       }
  624. }
  625.  
  626. /* Return the previous frame in the frame list before FRAME.
  627.    If MINIBUF is nil, exclude minibuffer-only frames.
  628.    If MINIBUF is a window, include only frames using that window for
  629.    their minibuffer.
  630.    If MINIBUF is `visible', include all visible frames.
  631.    Otherwise, include all frames.  */
  632.  
  633. Lisp_Object
  634. prev_frame (frame, minibuf)
  635.      Lisp_Object frame;
  636.      Lisp_Object minibuf;
  637. {
  638.   Lisp_Object tail;
  639.   Lisp_Object prev;
  640.  
  641.   /* There must always be at least one frame in Vframe_list.  */
  642.   if (! CONSP (Vframe_list))
  643.     abort ();
  644.  
  645.   prev = Qnil;
  646.   for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
  647.     {
  648.       Lisp_Object f;
  649.  
  650.       f = XCONS (tail)->car;
  651.       if (XTYPE (f) != Lisp_Frame)
  652.     abort ();
  653.  
  654.       if (EQ (frame, f) && !NILP (prev))
  655.     return prev;
  656.  
  657.       /* Decide whether this frame is eligible to be returned,
  658.      according to minibuf.  */
  659.       if (NILP (minibuf))
  660.     {
  661.       if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
  662.         prev = f;
  663.     }
  664.       else if (XTYPE (minibuf) == Lisp_Window)
  665.     {
  666.       if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf))
  667.         prev = f;
  668.     }
  669.       else if (EQ (minibuf, Qvisible))
  670.     {
  671.       FRAME_SAMPLE_VISIBILITY (XFRAME (f));
  672.       if (FRAME_VISIBLE_P (XFRAME (f)))
  673.         prev = f;
  674.     }
  675.       else
  676.     prev = f;
  677.     }
  678.  
  679.   /* We've scanned the entire list.  */
  680.   if (NILP (prev))
  681.     /* We went through the whole frame list without finding a single
  682.        acceptable frame.  Return the original frame.  */
  683.     return frame;
  684.   else
  685.     /* There were no acceptable frames in the list before FRAME; otherwise,
  686.        we would have returned directly from the loop.  Since PREV is the last
  687.        acceptable frame in the list, return it.  */
  688.     return prev;
  689. }
  690.  
  691.  
  692. DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
  693.   "Return the next frame in the frame list after FRAME.\n\
  694. By default, skip minibuffer-only frames.\n\
  695. If omitted, FRAME defaults to the selected frame.\n\
  696. If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
  697. If MINIFRAME is a window, include only frames using that window for their\n\
  698. minibuffer.\n\
  699. If MINIFRAME is `visible', include all visible frames.\n\
  700. Otherwise, include all frames.")
  701.   (frame, miniframe)
  702.      Lisp_Object frame, miniframe;
  703. {
  704.   Lisp_Object tail;
  705.  
  706.   if (NILP (frame))
  707.     XSET (frame, Lisp_Frame, selected_frame);
  708.   else
  709.     CHECK_LIVE_FRAME (frame, 0);
  710.  
  711.   return next_frame (frame, miniframe);
  712. }
  713.  
  714. DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0,
  715.   "Return the previous frame in the frame list before FRAME.\n\
  716. By default, skip minibuffer-only frames.\n\
  717. If omitted, FRAME defaults to the selected frame.\n\
  718. If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
  719. If MINIFRAME is a window, include only frames using that window for their\n\
  720. minibuffer.\n\
  721. If MINIFRAME is `visible', include all visible frames.\n\
  722. Otherwise, include all frames.")
  723.   (frame, miniframe)
  724.      Lisp_Object frame, miniframe;
  725. {
  726.   Lisp_Object tail;
  727.  
  728.   if (NILP (frame))
  729.     XSET (frame, Lisp_Frame, selected_frame);
  730.   else
  731.     CHECK_LIVE_FRAME (frame, 0);
  732.  
  733.   return prev_frame (frame, miniframe);
  734. }
  735.  
  736. /* Return 1 if it is ok to delete frame F;
  737.    0 if all frames aside from F are invisible.
  738.    (Exception: if F is the terminal frame, and we are using X, return 1.)  */
  739.  
  740. int
  741. other_visible_frames (f)
  742.      FRAME_PTR f;
  743. {
  744.   /* We know the selected frame is visible,
  745.      so if F is some other frame, it can't be the sole visible one.  */
  746.   if (f == selected_frame)
  747.     {
  748.       Lisp_Object frames;
  749.       int count = 0;
  750.  
  751.       for (frames = Vframe_list;
  752.        CONSP (frames);
  753.        frames = XCONS (frames)->cdr)
  754.     {
  755.       Lisp_Object this;
  756.  
  757.       this = XCONS (frames)->car;
  758.       /* Verify that the frame's window still exists
  759.          and we can still talk to it.  And note any recent change
  760.          in visibility.  */
  761. #ifdef HAVE_X_WINDOWS
  762.       if (FRAME_X_P (XFRAME (this)))
  763.         {
  764.           x_sync (this);
  765.           FRAME_SAMPLE_VISIBILITY (XFRAME (this));
  766.         }
  767. #endif
  768.  
  769.       if (FRAME_VISIBLE_P (XFRAME (this))
  770.           || FRAME_ICONIFIED_P (XFRAME (this))
  771.           /* Allow deleting the terminal frame when at least
  772.          one X frame exists!  */
  773.           || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f)))
  774.         count++;
  775.     }
  776.       return count > 1;
  777.     }
  778.   return 1;
  779. }
  780.  
  781. DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
  782.   "Delete FRAME, permanently eliminating it from use.\n\
  783. If omitted, FRAME defaults to the selected frame.\n\
  784. A frame may not be deleted if its minibuffer is used by other frames.\n\
  785. Normally, you may not delete a frame if all other frames are invisible,\n\
  786. but if the second optional argument FORCE is non-nil, you may do so.")
  787.   (frame, force)
  788.      Lisp_Object frame, force;
  789. {
  790.   struct frame *f;
  791.  
  792.   if (EQ (frame, Qnil))
  793.     {
  794.       f = selected_frame;
  795.       XSET (frame, Lisp_Frame, f);
  796.     }
  797.   else
  798.     {
  799.       CHECK_FRAME (frame, 0);
  800.       f = XFRAME (frame);
  801.     }
  802.  
  803.   if (! FRAME_LIVE_P (f))
  804.     return Qnil;
  805.  
  806.   if (NILP (force) && !other_visible_frames (f))
  807.     error ("Attempt to delete the sole visible or iconified frame");
  808.  
  809.   /* Does this frame have a minibuffer, and is it the surrogate
  810.      minibuffer for any other frame?  */
  811.   if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
  812.     {
  813.       Lisp_Object frames;
  814.  
  815.       for (frames = Vframe_list;
  816.        CONSP (frames);
  817.        frames = XCONS (frames)->cdr)
  818.     {
  819.       Lisp_Object this;
  820.       this = XCONS (frames)->car;
  821.  
  822.       if (! EQ (this, frame)
  823.           && EQ (frame,
  824.              WINDOW_FRAME (XWINDOW
  825.                    (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
  826.         error ("Attempt to delete a surrogate minibuffer frame");
  827.     }
  828.     }
  829.  
  830.   /* Don't let the frame remain selected.  */
  831.   if (f == selected_frame)
  832.     Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
  833.  
  834.   /* Don't allow minibuf_window to remain on a deleted frame.  */
  835.   if (EQ (f->minibuffer_window, minibuf_window))
  836.     {
  837.       Fset_window_buffer (selected_frame->minibuffer_window,
  838.               XWINDOW (minibuf_window)->buffer);
  839.       minibuf_window = selected_frame->minibuffer_window;
  840.     }
  841.  
  842.   /* Mark all the windows that used to be on FRAME as deleted, and then
  843.      remove the reference to them.  */
  844.   delete_all_subwindows (XWINDOW (f->root_window));
  845.   f->root_window = Qnil;
  846.  
  847.   Vframe_list = Fdelq (frame, Vframe_list);
  848.   FRAME_SET_VISIBLE (f, 0);
  849.  
  850.   /* Since some events are handled at the interrupt level, we may get
  851.      an event for f at any time; if we zero out the frame's display
  852.      now, then we may trip up the event-handling code.  Instead, we'll
  853.      promise that the display of the frame must be valid until we have
  854.      called the window-system-dependent frame destruction routine.  */
  855.  
  856.   /* I think this should be done with a hook.  */
  857. #ifdef HAVE_X_WINDOWS
  858.   if (FRAME_X_P (f))
  859.     x_destroy_window (f);
  860. #endif
  861.  
  862.   f->display.nothing = 0;
  863.  
  864.   /* If we've deleted the last_nonminibuf_frame, then try to find
  865.      another one.  */
  866.   if (f == last_nonminibuf_frame)
  867.     {
  868.       Lisp_Object frames;
  869.  
  870.       last_nonminibuf_frame = 0;
  871.  
  872.       for (frames = Vframe_list;
  873.        CONSP (frames);
  874.        frames = XCONS (frames)->cdr)
  875.     {
  876.       f = XFRAME (XCONS (frames)->car);
  877.       if (!FRAME_MINIBUF_ONLY_P (f))
  878.         {
  879.           last_nonminibuf_frame = f;
  880.           break;
  881.         }
  882.     }
  883.     }
  884.  
  885.   /* If we've deleted Vdefault_minibuffer_frame, try to find another
  886.      one.  Prefer minibuffer-only frames, but also notice frames
  887.      with other windows.  */
  888.   if (EQ (frame, Vdefault_minibuffer_frame))
  889.     {
  890.       Lisp_Object frames;
  891.  
  892.       /* The last frame we saw with a minibuffer, minibuffer-only or not.  */
  893.       Lisp_Object frame_with_minibuf;
  894.  
  895.       frame_with_minibuf = Qnil;
  896.       for (frames = Vframe_list;
  897.        CONSP (frames);
  898.        frames = XCONS (frames)->cdr)
  899.     {
  900.       Lisp_Object this;
  901.  
  902.       this = XCONS (frames)->car;
  903.       if (XTYPE (this) != Lisp_Frame)
  904.         abort ();
  905.       f = XFRAME (this);
  906.  
  907.       if (FRAME_HAS_MINIBUF_P (f))
  908.         {
  909.           frame_with_minibuf = this;
  910.           if (FRAME_MINIBUF_ONLY_P (f))
  911.         break;
  912.         }
  913.     }
  914.  
  915.       /* We know that there must be some frame with a minibuffer out
  916.      there.  If this were not true, all of the frames present
  917.      would have to be minibufferless, which implies that at some
  918.      point their minibuffer frames must have been deleted, but
  919.      that is prohibited at the top; you can't delete surrogate
  920.      minibuffer frames.  */
  921.       if (NILP (frame_with_minibuf))
  922.     abort ();
  923.  
  924.       Vdefault_minibuffer_frame = frame_with_minibuf;
  925.     }
  926.  
  927.   return Qnil;
  928. }
  929.  
  930. /* Return mouse position in character cell units.  */
  931.  
  932. DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
  933.   "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
  934. The position is given in character cells, where (0, 0) is the\n\
  935. upper-left corner.\n\
  936. If Emacs is running on a mouseless terminal or hasn't been programmed\n\
  937. to read the mouse position, it returns the selected frame for FRAME\n\
  938. and nil for X and Y.")
  939.   ()
  940. {
  941.   FRAME_PTR f;
  942.   Lisp_Object lispy_dummy;
  943.   enum scroll_bar_part party_dummy;
  944.   Lisp_Object x, y;
  945.   int col, row;
  946.   unsigned long long_dummy;
  947.  
  948.   f = selected_frame;
  949.   x = y = Qnil;
  950.  
  951.   /* It's okay for the hook to refrain from storing anything.  */
  952.   if (mouse_position_hook)
  953.     (*mouse_position_hook) (&f,
  954.                 &lispy_dummy, &party_dummy,
  955.                 &x, &y,
  956.                 &long_dummy);
  957.   if (! NILP (x))
  958.     {
  959.       col = XINT (x);
  960.       row = XINT (y);
  961.       pixel_to_glyph_coords (f, col, row, &col, &row, 0, 1);
  962.       XSETINT (x, col);
  963.       XSETINT (y, row);
  964.     }
  965.   XSET (lispy_dummy, Lisp_Frame, f);
  966.   return Fcons (lispy_dummy, Fcons (x, y));
  967. }
  968.  
  969. DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
  970.        Smouse_pixel_position, 0, 0, 0,
  971.   "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
  972. The position is given in pixel units, where (0, 0) is the\n\
  973. upper-left corner.\n\
  974. If Emacs is running on a mouseless terminal or hasn't been programmed\n\
  975. to read the mouse position, it returns the selected frame for FRAME\n\
  976. and nil for X and Y.")
  977.   ()
  978. {
  979.   FRAME_PTR f;
  980.   Lisp_Object lispy_dummy;
  981.   enum scroll_bar_part party_dummy;
  982.   Lisp_Object x, y;
  983.   int col, row;
  984.   unsigned long long_dummy;
  985.  
  986.   f = selected_frame;
  987.   x = y = Qnil;
  988.  
  989.   /* It's okay for the hook to refrain from storing anything.  */
  990.   if (mouse_position_hook)
  991.     (*mouse_position_hook) (&f,
  992.                 &lispy_dummy, &party_dummy,
  993.                 &x, &y,
  994.                 &long_dummy);
  995.   XSET (lispy_dummy, Lisp_Frame, f);
  996.   return Fcons (lispy_dummy, Fcons (x, y));
  997. }
  998.  
  999. DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
  1000.   "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
  1001. WARNING:  If you use this under X windows,\n\
  1002. you should call `unfocus-frame' afterwards.")
  1003.   (frame, x, y)
  1004.      Lisp_Object frame, x, y;
  1005. {
  1006.   CHECK_LIVE_FRAME (frame, 0);
  1007.   CHECK_NUMBER (x, 2);
  1008.   CHECK_NUMBER (y, 1);
  1009.  
  1010.   /* I think this should be done with a hook.  */
  1011. #ifdef HAVE_X_WINDOWS
  1012.   if (FRAME_X_P (XFRAME (frame)))
  1013.     /* Warping the mouse will cause  enternotify and focus events. */
  1014.     x_set_mouse_position (XFRAME (frame), x, y);
  1015. #endif
  1016.  
  1017.   return Qnil;
  1018. }
  1019.  
  1020. DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
  1021.        Sset_mouse_pixel_position, 3, 3, 0,
  1022.   "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
  1023. WARNING:  If you use this under X windows,\n\
  1024. you should call `unfocus-frame' afterwards.")
  1025.   (frame, x, y)
  1026.      Lisp_Object frame, x, y;
  1027. {
  1028.   CHECK_LIVE_FRAME (frame, 0);
  1029.   CHECK_NUMBER (x, 2);
  1030.   CHECK_NUMBER (y, 1);
  1031.  
  1032.   /* I think this should be done with a hook.  */
  1033. #ifdef HAVE_X_WINDOWS
  1034.   if (FRAME_X_P (XFRAME (frame)))
  1035.     /* Warping the mouse will cause  enternotify and focus events. */
  1036.     x_set_mouse_pixel_position (XFRAME (frame), x, y);
  1037. #endif
  1038.  
  1039.   return Qnil;
  1040. }
  1041. #endif
  1042.  
  1043. #ifdef AMIGA
  1044. DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
  1045.        0, 1, "",
  1046.   "Make the frame FRAME visible (assuming it is an X-window).\n\
  1047. If omitted, FRAME defaults to the currently selected frame.")
  1048.   (frame)
  1049.      Lisp_Object frame;
  1050. {
  1051. #ifdef MULTI_FRAME
  1052.   if (NILP (frame))
  1053.     XSET (frame, Lisp_Frame, selected_frame);
  1054. #endif
  1055.   
  1056.   CHECK_LIVE_FRAME (frame, 0);
  1057.  
  1058.   /* I think this should be done with a hook.  */
  1059. #if defined(HAVE_X_WINDOWS) || defined(AMIGA)
  1060.   if (FRAME_X_P (XFRAME (frame)))
  1061.     {
  1062.       FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
  1063.       x_make_frame_visible (XFRAME (frame));
  1064.     }
  1065. #endif
  1066.  
  1067.   return frame;
  1068. }
  1069. #endif
  1070. #ifdef MULTI_FRAME
  1071. DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
  1072.        0, 2, "",
  1073.   "Make the frame FRAME invisible (assuming it is an X-window).\n\
  1074. If omitted, FRAME defaults to the currently selected frame.\n\
  1075. Normally you may not make FRAME invisible if all other frames are invisible,\n\
  1076. but if the second optional argument FORCE is non-nil, you may do so.")
  1077.   (frame, force)
  1078.      Lisp_Object frame, force;
  1079. {
  1080.   if (NILP (frame))
  1081.     XSET (frame, Lisp_Frame, selected_frame);
  1082.  
  1083.   CHECK_LIVE_FRAME (frame, 0);
  1084.  
  1085.   if (NILP (force) && !other_visible_frames (XFRAME (frame)))
  1086.     error ("Attempt to make invisible the sole visible or iconified frame");
  1087.  
  1088.   /* Don't let the frame remain selected.  */
  1089.   if (XFRAME (frame) == selected_frame)
  1090.     Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
  1091.  
  1092.   /* Don't allow minibuf_window to remain on a deleted frame.  */
  1093.   if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
  1094.     {
  1095.       Fset_window_buffer (selected_frame->minibuffer_window,
  1096.               XWINDOW (minibuf_window)->buffer);
  1097.       minibuf_window = selected_frame->minibuffer_window;
  1098.     }
  1099.  
  1100.   /* I think this should be done with a hook.  */
  1101. #ifdef HAVE_X_WINDOWS
  1102.   if (FRAME_X_P (XFRAME (frame)))
  1103.     x_make_frame_invisible (XFRAME (frame));
  1104. #endif
  1105.  
  1106.   return Qnil;
  1107. }
  1108.  
  1109. DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
  1110.        0, 1, "",
  1111.   "Make the frame FRAME into an icon.\n\
  1112. If omitted, FRAME defaults to the currently selected frame.")
  1113.   (frame)
  1114.      Lisp_Object frame;
  1115. {
  1116.   if (NILP (frame))
  1117.     XSET (frame, Lisp_Frame, selected_frame);
  1118.   
  1119.   CHECK_LIVE_FRAME (frame, 0);
  1120.  
  1121.   /* Don't let the frame remain selected.  */
  1122.   if (XFRAME (frame) == selected_frame)
  1123.     Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
  1124.  
  1125.   /* Don't allow minibuf_window to remain on a deleted frame.  */
  1126.   if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
  1127.     {
  1128.       Fset_window_buffer (selected_frame->minibuffer_window,
  1129.               XWINDOW (minibuf_window)->buffer);
  1130.       minibuf_window = selected_frame->minibuffer_window;
  1131.     }
  1132.  
  1133.   /* I think this should be done with a hook.  */
  1134. #ifdef HAVE_X_WINDOWS
  1135.   if (FRAME_X_P (XFRAME (frame)))
  1136.       x_iconify_frame (XFRAME (frame));
  1137. #endif
  1138.  
  1139.   return Qnil;
  1140. }
  1141.  
  1142. DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
  1143.        1, 1, 0,
  1144.        "Return t if FRAME is now \"visible\" (actually in use for display).\n\
  1145. A frame that is not \"visible\" is not updated and, if it works through\n\
  1146. a window system, it may not show at all.\n\
  1147. Return the symbol `icon' if frame is visible only as an icon.")
  1148.   (frame)
  1149.      Lisp_Object frame;
  1150. {
  1151.   CHECK_LIVE_FRAME (frame, 0);
  1152.  
  1153.   FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
  1154.  
  1155.   if (FRAME_VISIBLE_P (XFRAME (frame)))
  1156.     return Qt;
  1157.   if (FRAME_ICONIFIED_P (XFRAME (frame)))
  1158.     return Qicon;
  1159.   return Qnil;
  1160. }
  1161.  
  1162. DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
  1163.        0, 0, 0,
  1164.        "Return a list of all frames now \"visible\" (being updated).")
  1165.   ()
  1166. {
  1167.   Lisp_Object tail, frame;
  1168.   struct frame *f;
  1169.   Lisp_Object value;
  1170.  
  1171.   value = Qnil;
  1172.   for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
  1173.     {
  1174.       frame = XCONS (tail)->car;
  1175.       if (XTYPE (frame) != Lisp_Frame)
  1176.     continue;
  1177.       f = XFRAME (frame);
  1178.       if (FRAME_VISIBLE_P (f))
  1179.     value = Fcons (frame, value);
  1180.     }
  1181.   return value;
  1182. }
  1183. #endif
  1184. #ifdef AMIGA
  1185. DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 1, 1, 0,
  1186.   "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
  1187. If FRAME is invisible, make it visible.\n\
  1188. If Emacs is displaying on an ordinary terminal or some other device which\n\
  1189. doesn't support multiple overlapping frames, this function does nothing.")
  1190.   (frame)
  1191.      Lisp_Object frame;
  1192. {
  1193.   CHECK_LIVE_FRAME (frame, 0);
  1194.  
  1195.   /* Do like the documentation says. */
  1196.   Fmake_frame_visible (frame);
  1197.  
  1198.   if (frame_raise_lower_hook)
  1199.     (*frame_raise_lower_hook) (XFRAME (frame), 1);
  1200.  
  1201.   return Qnil;
  1202. }
  1203.  
  1204. /* Should we have a corresponding function called Flower_Power?  */
  1205. DEFUN ("lower-frame", Flower_frame, Slower_frame, 1, 1, 0,
  1206.   "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
  1207. If Emacs is displaying on an ordinary terminal or some other device which\n\
  1208. doesn't support multiple overlapping frames, this function does nothing.")
  1209.   (frame)
  1210.      Lisp_Object frame;
  1211. {
  1212.   CHECK_LIVE_FRAME (frame, 0);
  1213.   
  1214.   if (frame_raise_lower_hook)
  1215.     (*frame_raise_lower_hook) (XFRAME (frame), 0);
  1216.  
  1217.   return Qnil;
  1218. }
  1219. #ifdef MULTI_FRAME
  1220.  
  1221. DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
  1222.        1, 2, 0,
  1223.   "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
  1224. In other words, switch-frame events caused by events in FRAME will\n\
  1225. request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
  1226. FOCUS-FRAME after reading an event typed at FRAME.\n\
  1227. \n\
  1228. If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
  1229. cancelled, and the frame again receives its own keystrokes.\n\
  1230. \n\
  1231. Focus redirection is useful for temporarily redirecting keystrokes to\n\
  1232. a surrogate minibuffer frame when a frame doesn't have its own\n\
  1233. minibuffer window.\n\
  1234. \n\
  1235. A frame's focus redirection can be changed by select-frame.  If frame\n\
  1236. FOO is selected, and then a different frame BAR is selected, any\n\
  1237. frames redirecting their focus to FOO are shifted to redirect their\n\
  1238. focus to BAR.  This allows focus redirection to work properly when the\n\
  1239. user switches from one frame to another using `select-window'.\n\
  1240. \n\
  1241. This means that a frame whose focus is redirected to itself is treated\n\
  1242. differently from a frame whose focus is redirected to nil; the former\n\
  1243. is affected by select-frame, while the latter is not.\n\
  1244. \n\
  1245. The redirection lasts until `redirect-frame-focus' is called to change it.")
  1246.   (frame, focus_frame)
  1247.     Lisp_Object frame, focus_frame;
  1248. {
  1249.   /* Note that we don't check for a live frame here.  It's reasonable
  1250.      to redirect the focus of a frame you're about to delete, if you
  1251.      know what other frame should receive those keystrokes.  */
  1252.   CHECK_FRAME (frame, 0);
  1253.  
  1254.   if (! NILP (focus_frame))
  1255.     CHECK_LIVE_FRAME (focus_frame, 1);
  1256.  
  1257.   XFRAME (frame)->focus_frame = focus_frame;
  1258.  
  1259.   /* I think this should be done with a hook.  */
  1260. #ifdef HAVE_X_WINDOWS
  1261.   if (!NILP (focus_frame) && ! EQ (focus_frame, frame)
  1262.       && FRAME_X_P (XFRAME (focus_frame)))
  1263.     Ffocus_frame (focus_frame);
  1264. #endif
  1265.  
  1266.   if (frame_rehighlight_hook)
  1267.     (*frame_rehighlight_hook) ();
  1268.   
  1269.   return Qnil;
  1270. }
  1271.  
  1272.  
  1273. DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
  1274.   "Return the frame to which FRAME's keystrokes are currently being sent.\n\
  1275. This returns nil if FRAME's focus is not redirected.\n\
  1276. See `redirect-frame-focus'.")
  1277.   (frame)
  1278.     Lisp_Object frame;
  1279. {
  1280.   CHECK_LIVE_FRAME (frame, 0);
  1281.  
  1282.   return FRAME_FOCUS_FRAME (XFRAME (frame));
  1283. }
  1284.  
  1285.  
  1286.  
  1287. #endif
  1288. #ifdef AMIGA
  1289. void
  1290. store_in_alist (alistptr, prop, val)
  1291.      Lisp_Object *alistptr, val;
  1292.      Lisp_Object prop;
  1293. {
  1294.   register Lisp_Object tem;
  1295.  
  1296.   tem = Fassq (prop, *alistptr);
  1297.   if (EQ (tem, Qnil))
  1298.     *alistptr = Fcons (Fcons (prop, val), *alistptr);
  1299.   else
  1300.     Fsetcdr (tem, val);
  1301. }
  1302. #endif
  1303. #ifdef AMIGA /* CHFIXME */
  1304. #ifndef MULTI_FRAME
  1305. #ifdef USE_EXTERNAL_MENU_BAR
  1306. Lisp_Object the_only_param_alist; /* can\'t store it in the_only_window, it\'s collectile */
  1307. Lisp_Object the_only_menu_bar_items; /* can\'t store it in the_only_window, it\'s collectile */
  1308. Lisp_Object the_only_menu_bar_vector; /* can\'t store it in the_only_window, it\'s collectile */
  1309. #endif
  1310. #ifdef USE_SCROLL_BARS
  1311. Lisp_Object the_only_scroll_bars;
  1312. Lisp_Object the_only_condemned_scroll_bars;
  1313. #endif
  1314. #endif
  1315. Lisp_Object
  1316. get_frame_param (frame, prop)
  1317.      FRAME_PTR frame;
  1318.      Lisp_Object prop;
  1319. {
  1320.   register Lisp_Object tem;
  1321.  
  1322.   tem = Fassq (prop, FRAME_PARAM_ALIST(f));
  1323.   if (EQ (tem, Qnil))
  1324.     return tem;
  1325.   return Fcdr (tem);
  1326. }
  1327.  
  1328. extern Lisp_Object Qminibuffer; /* comes at end of this file CHFIXME */
  1329.  
  1330. void
  1331. store_frame_param (f, prop, val)
  1332.      FRAME_PTR f;
  1333.      Lisp_Object prop, val;
  1334. {
  1335.   register Lisp_Object tem;
  1336.  
  1337.   tem = Fassq (prop, FRAME_PARAM_ALIST(f));
  1338.   if (EQ (tem, Qnil))
  1339.     FRAME_PARAM_ALIST(f) = Fcons (Fcons (prop, val), FRAME_PARAM_ALIST(f));
  1340.   else
  1341.     Fsetcdr (tem, val);
  1342.  
  1343. #ifndef AMIGA /* CHFIXME meaning ? */
  1344.   if (EQ (prop, Qminibuffer)
  1345.       && XTYPE (val) == Lisp_Window)
  1346.     {
  1347.       if (! MINI_WINDOW_P (XWINDOW (val)))
  1348.     error ("Surrogate minibuffer windows must be minibuffer windows.");
  1349.  
  1350.       if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
  1351.     error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
  1352.  
  1353.       /* Install the chosen minibuffer window, with proper buffer.  */
  1354.       FRAME_MINIBUF_WINDOW(W) = val;
  1355.     }
  1356. #endif
  1357. }
  1358. #endif /* AMIGA */
  1359.  
  1360. #ifdef AMIGA
  1361. /* CHFIXME: defined below */
  1362.  
  1363. extern Lisp_Object Qname;
  1364. extern Lisp_Object Qheight;
  1365. extern Lisp_Object Qwidth;
  1366. extern Lisp_Object Qmodeline;
  1367. extern Lisp_Object Qminibuffer;
  1368. extern Lisp_Object Qunsplittable;
  1369. extern Lisp_Object Qmenu_bar_lines;
  1370.  
  1371. DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
  1372.   "Return the parameters-alist of frame FRAME.\n\
  1373. It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
  1374. The meaningful PARMs depend on the kind of frame.\n\
  1375. If FRAME is omitted, return information on the currently selected frame.")
  1376.   (frame)
  1377.      Lisp_Object frame;
  1378. {
  1379.   Lisp_Object alist;
  1380.   FRAME_PTR f;
  1381.  
  1382.   if (EQ (frame, Qnil))
  1383.     f = selected_frame;
  1384.   else
  1385.     {
  1386.       CHECK_FRAME (frame, 0);
  1387.       f = XFRAME (frame);
  1388.     }
  1389.  
  1390.   if (!FRAME_LIVE_P (f))
  1391.     return Qnil;
  1392.  
  1393.   alist = Fcopy_alist (FRAME_PARAM_ALIST(f));
  1394.  
  1395. #ifdef AMIGA /* CHFIXME */
  1396.   store_in_alist (&alist, Qname, build_string ("emacs"));
  1397. #else
  1398.   store_in_alist (&alist, Qname, f->name);
  1399. #endif
  1400.   store_in_alist (&alist, Qheight, make_number (FRAME_HEIGHT (f)));
  1401.   store_in_alist (&alist, Qwidth, make_number (FRAME_WIDTH (f)));
  1402.   store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil));
  1403.   store_in_alist (&alist, Qminibuffer,
  1404.           (! FRAME_HAS_MINIBUF_P (f) ? Qnil
  1405. #ifndef AMIGA /* CHFIXME: meaning? */
  1406.            : FRAME_MINIBUF_ONLY_P (f) ? Qonly
  1407. #endif
  1408.            : FRAME_MINIBUF_WINDOW (f)));
  1409.   store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
  1410.   store_in_alist (&alist, Qmenu_bar_lines, (FRAME_MENU_BAR_LINES (f)));
  1411.  
  1412.   /* I think this should be done with a hook.  */
  1413. #ifdef HAVE_X_WINDOWS
  1414.   if (FRAME_X_P (f))
  1415.     x_report_frame_params (f, &alist);
  1416. #endif
  1417. #ifdef AMIGA /* CHFIXME */
  1418.   {
  1419.     if (EMACS_WIN(f))
  1420.     x_report_frame_params (f, &alist);
  1421.   }
  1422. #endif
  1423.   return alist;
  1424. }
  1425. #endif
  1426. #ifdef AMIGA
  1427. DEFUN ("modify-frame-parameters", Fmodify_frame_parameters, 
  1428.        Smodify_frame_parameters, 2, 2, 0,
  1429.   "Modify the parameters of frame FRAME according to ALIST.\n\
  1430. ALIST is an alist of parameters to change and their new values.\n\
  1431. Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
  1432. The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
  1433.   (frame, alist)
  1434.      Lisp_Object frame, alist;
  1435. {
  1436.   FRAME_PTR f;
  1437.   register Lisp_Object tail, elt, prop, val;
  1438.  
  1439.   if (EQ (frame, Qnil))
  1440.     f = selected_frame;
  1441.   else
  1442.     {
  1443.       CHECK_LIVE_FRAME (frame, 0);
  1444.       f = XFRAME (frame);
  1445.     }
  1446.  
  1447.   /* I think this should be done with a hook.  */
  1448. #ifdef HAVE_X_WINDOWS
  1449.   if (FRAME_X_P (f))
  1450. #if 1
  1451.     x_set_frame_parameters (f, alist);
  1452. #else
  1453.     for (tail = alist; !EQ (tail, Qnil); tail = Fcdr (tail))
  1454.       {
  1455.     elt = Fcar (tail);
  1456.     prop = Fcar (elt);
  1457.     val = Fcdr (elt);
  1458.     x_set_frame_param (f, prop, val, get_frame_param (f, prop));
  1459.     store_frame_param (f, prop, val);
  1460.       }
  1461. #endif
  1462. #endif
  1463.  
  1464. #ifdef AMIGA /* CHFIXME */
  1465.   {
  1466.     if (EMACS_WIN(f))
  1467.       x_set_frame_parameters (f, alist);
  1468.   }
  1469. #endif
  1470.  
  1471.   return Qnil;
  1472. }
  1473. #endif /* AMIGA */
  1474.  
  1475. #ifdef MULTI_FRAME
  1476. DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
  1477.   0, 1, 0,
  1478.   "Height in pixels of a line in the font in frame FRAME.\n\
  1479. If FRAME is omitted, the selected frame is used.\n\
  1480. For a terminal frame, the value is always 1.")
  1481.   (frame)
  1482.      Lisp_Object frame;
  1483. {
  1484.   struct frame *f;
  1485.  
  1486.   if (NILP (frame))
  1487.     f = selected_frame;
  1488.   else
  1489.     {
  1490.       CHECK_FRAME (frame, 0);
  1491.       f = XFRAME (frame);
  1492.     }
  1493.  
  1494. #ifdef HAVE_X_WINDOWS
  1495.   if (FRAME_X_P (f))
  1496.     return make_number (x_char_height (f));
  1497.   else
  1498. #endif
  1499.     return make_number (1);
  1500. }
  1501.  
  1502.  
  1503. DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
  1504.   0, 1, 0,
  1505.   "Width in pixels of characters in the font in frame FRAME.\n\
  1506. If FRAME is omitted, the selected frame is used.\n\
  1507. The width is the same for all characters, because\n\
  1508. currently Emacs supports only fixed-width fonts.\n\
  1509. For a terminal screen, the value is always 1.")
  1510.   (frame)
  1511.      Lisp_Object frame;
  1512. {
  1513.   struct frame *f;
  1514.  
  1515.   if (NILP (frame))
  1516.     f = selected_frame;
  1517.   else
  1518.     {
  1519.       CHECK_FRAME (frame, 0);
  1520.       f = XFRAME (frame);
  1521.     }
  1522.  
  1523. #ifdef HAVE_X_WINDOWS
  1524.   if (FRAME_X_P (f))
  1525.     return make_number (x_char_width (f));
  1526.   else
  1527. #endif
  1528.     return make_number (1);
  1529. }
  1530.  
  1531. DEFUN ("frame-pixel-height", Fframe_pixel_height, 
  1532.        Sframe_pixel_height, 0, 1, 0,
  1533.   "Return a FRAME's height in pixels.\n\
  1534. For a terminal frame, the result really gives the height in characters.\n\
  1535. If FRAME is omitted, the selected frame is used.")
  1536.   (frame)
  1537.      Lisp_Object frame;
  1538. {
  1539.   struct frame *f;
  1540.  
  1541.   if (NILP (frame))
  1542.     f = selected_frame;
  1543.   else
  1544.     {
  1545.       CHECK_FRAME (frame, 0);
  1546.       f = XFRAME (frame);
  1547.     }
  1548.  
  1549. #ifdef HAVE_X_WINDOWS
  1550.   if (FRAME_X_P (f))
  1551.     return make_number (x_pixel_height (f));
  1552.   else
  1553. #endif
  1554.     return make_number (FRAME_HEIGHT (f));
  1555. }
  1556.  
  1557. DEFUN ("frame-pixel-width", Fframe_pixel_width, 
  1558.        Sframe_pixel_width, 0, 1, 0,
  1559.   "Return FRAME's width in pixels.\n\
  1560. For a terminal frame, the result really gives the width in characters.\n\
  1561. If FRAME is omitted, the selected frame is used.")
  1562.   (frame)
  1563.      Lisp_Object frame;
  1564. {
  1565.   struct frame *f;
  1566.  
  1567.   if (NILP (frame))
  1568.     f = selected_frame;
  1569.   else
  1570.     {
  1571.       CHECK_FRAME (frame, 0);
  1572.       f = XFRAME (frame);
  1573.     }
  1574.  
  1575. #ifdef HAVE_X_WINDOWS
  1576.   if (FRAME_X_P (f))
  1577.     return make_number (x_pixel_width (f));
  1578.   else
  1579. #endif
  1580.     return make_number (FRAME_WIDTH (f));
  1581. }
  1582.  
  1583. DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
  1584.   "Specify that the frame FRAME has LINES lines.\n\
  1585. Optional third arg non-nil means that redisplay should use LINES lines\n\
  1586. but that the idea of the actual height of the frame should not be changed.")
  1587.   (frame, rows, pretend)
  1588.      Lisp_Object frame, rows, pretend;
  1589. {
  1590.   register struct frame *f;
  1591.  
  1592.   CHECK_NUMBER (rows, 0);
  1593.   if (NILP (frame))
  1594.     f = selected_frame;
  1595.   else
  1596.     {
  1597.       CHECK_LIVE_FRAME (frame, 0);
  1598.       f = XFRAME (frame);
  1599.     }
  1600.  
  1601.   /* I think this should be done with a hook.  */
  1602. #ifdef HAVE_X_WINDOWS
  1603.   if (FRAME_X_P (f))
  1604.     {
  1605.       if (XINT (rows) != f->width)
  1606.     x_set_window_size (f, 1, f->width, XINT (rows));
  1607.     }
  1608.   else
  1609. #endif
  1610.     change_frame_size (f, XINT (rows), 0, !NILP (pretend), 0);
  1611.   return Qnil;
  1612. }
  1613.  
  1614. DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
  1615.   "Specify that the frame FRAME has COLS columns.\n\
  1616. Optional third arg non-nil means that redisplay should use COLS columns\n\
  1617. but that the idea of the actual width of the frame should not be changed.")
  1618.   (frame, cols, pretend)
  1619.      Lisp_Object frame, cols, pretend;
  1620. {
  1621.   register struct frame *f;
  1622.   CHECK_NUMBER (cols, 0);
  1623.   if (NILP (frame))
  1624.     f = selected_frame;
  1625.   else
  1626.     {
  1627.       CHECK_LIVE_FRAME (frame, 0);
  1628.       f = XFRAME (frame);
  1629.     }
  1630.  
  1631.   /* I think this should be done with a hook.  */
  1632. #ifdef HAVE_X_WINDOWS
  1633.   if (FRAME_X_P (f))
  1634.     {
  1635.       if (XINT (cols) != f->width)
  1636.     x_set_window_size (f, 1, XINT (cols), f->height);
  1637.     }
  1638.   else
  1639. #endif
  1640.     change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0);
  1641.   return Qnil;
  1642. }
  1643.  
  1644. DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
  1645.   "Sets size of FRAME to COLS by ROWS, measured in characters.")
  1646.   (frame, cols, rows)
  1647.      Lisp_Object frame, cols, rows;
  1648. {
  1649.   register struct frame *f;
  1650.   int mask;
  1651.  
  1652.   CHECK_LIVE_FRAME (frame, 0);
  1653.   CHECK_NUMBER (cols, 2);
  1654.   CHECK_NUMBER (rows, 1);
  1655.   f = XFRAME (frame);
  1656.  
  1657.   /* I think this should be done with a hook.  */
  1658. #ifdef HAVE_X_WINDOWS
  1659.   if (FRAME_X_P (f))
  1660.     {
  1661.       if (XINT (rows) != f->height || XINT (cols) != f->width)
  1662.     x_set_window_size (f, 1, XINT (cols), XINT (rows));
  1663.     }
  1664.   else
  1665. #endif
  1666.     change_frame_size (f, XINT (rows), XINT (cols), 0, 0);
  1667.  
  1668.   return Qnil;
  1669. }
  1670.  
  1671. DEFUN ("set-frame-position", Fset_frame_position, 
  1672.        Sset_frame_position, 3, 3, 0,
  1673.   "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
  1674. This is actually the position of the upper left corner of the frame.\n\
  1675. Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
  1676. the rightmost or bottommost possible position (that stays within the screen).")
  1677.   (frame, xoffset, yoffset)
  1678.      Lisp_Object frame, xoffset, yoffset;
  1679. {
  1680.   register struct frame *f;
  1681.   int mask;
  1682.  
  1683.   CHECK_LIVE_FRAME (frame, 0);
  1684.   CHECK_NUMBER (xoffset, 1);
  1685.   CHECK_NUMBER (yoffset, 2);
  1686.   f = XFRAME (frame);
  1687.  
  1688.   /* I think this should be done with a hook.  */
  1689. #ifdef HAVE_X_WINDOWS
  1690.   if (FRAME_X_P (f))
  1691.     x_set_offset (f, XINT (xoffset), XINT (yoffset), 1);
  1692. #endif
  1693.  
  1694.   return Qt;
  1695. }
  1696.  
  1697.  
  1698. choose_minibuf_frame ()
  1699. {
  1700.   /* For lowest-level minibuf, put it on currently selected frame
  1701.      if frame has a minibuffer.  */
  1702.  
  1703.   if (minibuf_level == 0
  1704.       && selected_frame != 0
  1705.       && !EQ (minibuf_window, selected_frame->minibuffer_window))
  1706.     {
  1707.       /* I don't think that any frames may validly have a null minibuffer
  1708.      window anymore.  */
  1709.       if (NILP (selected_frame->minibuffer_window))
  1710.     abort ();
  1711.  
  1712.       Fset_window_buffer (selected_frame->minibuffer_window,
  1713.               XWINDOW (minibuf_window)->buffer);
  1714.       minibuf_window = selected_frame->minibuffer_window;
  1715.     }
  1716. }
  1717.  
  1718. syms_of_frame ()
  1719. {
  1720.   /*&&& init symbols here &&&*/
  1721.   Qframep = intern ("framep");
  1722.   staticpro (&Qframep);
  1723.   Qframe_live_p = intern ("frame-live-p");
  1724.   staticpro (&Qframe_live_p);
  1725.   Qheight = intern ("height");
  1726.   staticpro (&Qheight);
  1727.   Qicon = intern ("icon");
  1728.   staticpro (&Qicon);
  1729.   Qminibuffer = intern ("minibuffer");
  1730.   staticpro (&Qminibuffer);
  1731.   Qmodeline = intern ("modeline");
  1732.   staticpro (&Qmodeline);
  1733.   Qname = intern ("name");
  1734.   staticpro (&Qname);
  1735.   Qonly = intern ("only");
  1736.   staticpro (&Qonly);
  1737.   Qunsplittable = intern ("unsplittable");
  1738.   staticpro (&Qunsplittable);
  1739.   Qmenu_bar_lines = intern ("menu-bar-lines");
  1740.   staticpro (&Qmenu_bar_lines);
  1741.   Qwidth = intern ("width");
  1742.   staticpro (&Qwidth);
  1743.   Qx = intern ("x");
  1744.   staticpro (&Qx);
  1745.   Qvisible = intern ("visible");
  1746.   staticpro (&Qvisible);
  1747.  
  1748.   staticpro (&Vframe_list);
  1749.  
  1750.   DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
  1751.     "The initial frame-object, which represents Emacs's stdout.");
  1752.  
  1753.   DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
  1754.     "Non-nil if all of emacs is iconified and frame updates are not needed.");
  1755.   Vemacs_iconified = Qnil;
  1756.  
  1757.   DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame,
  1758.     "Minibufferless frames use this frame's minibuffer.\n\
  1759. \n\
  1760. Emacs cannot create minibufferless frames unless this is set to an\n\
  1761. appropriate surrogate.\n\
  1762. \n\
  1763. Emacs consults this variable only when creating minibufferless\n\
  1764. frames; once the frame is created, it sticks with its assigned\n\
  1765. minibuffer, no matter what this variable is set to.  This means that\n\
  1766. this variable doesn't necessarily say anything meaningful about the\n\
  1767. current set of frames, or where the minibuffer is currently being\n\
  1768. displayed.");
  1769.   Vdefault_minibuffer_frame = Qnil;
  1770.  
  1771.   DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
  1772.     "Alist of default values for frame creation.\n\
  1773. These may be set in your init file, like this:\n\
  1774.   (setq default-frame-alist '((width . 80) (height . 55)))\n\
  1775. These override values given in window system configuration data, like\n\
  1776. X Windows' defaults database.\n\
  1777. For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
  1778. For values specific to the separate minibuffer frame, see\n\
  1779. `minibuffer-frame-alist'.");
  1780.   Vdefault_frame_alist = Qnil;
  1781.  
  1782.   defsubr (&Sframep);
  1783.   defsubr (&Sframe_live_p);
  1784.   defsubr (&Shandle_switch_frame);
  1785.   defsubr (&Sselect_frame);
  1786.   defsubr (&Sselected_frame);
  1787.   defsubr (&Swindow_frame);
  1788.   defsubr (&Sframe_root_window);
  1789.   defsubr (&Sframe_first_window);
  1790.   defsubr (&Sframe_selected_window);
  1791.   defsubr (&Sset_frame_selected_window);
  1792.   defsubr (&Sframe_list);
  1793.   defsubr (&Snext_frame);
  1794.   defsubr (&Sprevious_frame);
  1795.   defsubr (&Sdelete_frame);
  1796.   defsubr (&Smouse_position);
  1797.   defsubr (&Smouse_pixel_position);
  1798.   defsubr (&Sset_mouse_position);
  1799.   defsubr (&Sset_mouse_pixel_position);
  1800. #if 0
  1801.   defsubr (&Sframe_configuration);
  1802.   defsubr (&Srestore_frame_configuration);
  1803. #endif
  1804.   defsubr (&Smake_frame_visible);
  1805.   defsubr (&Smake_frame_invisible);
  1806.   defsubr (&Siconify_frame);
  1807.   defsubr (&Sframe_visible_p);
  1808.   defsubr (&Svisible_frame_list);
  1809.   defsubr (&Sraise_frame);
  1810.   defsubr (&Slower_frame);
  1811.   defsubr (&Sredirect_frame_focus);
  1812.   defsubr (&Sframe_focus);
  1813.   defsubr (&Sframe_parameters);
  1814.   defsubr (&Smodify_frame_parameters);
  1815.   defsubr (&Sframe_char_height);
  1816.   defsubr (&Sframe_char_width);
  1817.   defsubr (&Sframe_pixel_height);
  1818.   defsubr (&Sframe_pixel_width);
  1819.   defsubr (&Sset_frame_height);
  1820.   defsubr (&Sset_frame_width);
  1821.   defsubr (&Sset_frame_size);
  1822.   defsubr (&Sset_frame_position);
  1823. }
  1824.  
  1825. keys_of_frame ()
  1826. {
  1827.   initial_define_lispy_key (global_map, "switch-frame", "handle-switch-frame");
  1828. }
  1829.  
  1830. #else /* not MULTI_FRAME */
  1831.  
  1832. /* If we're not using multi-frame stuff, we still need to provide some
  1833.    support functions.  */
  1834.  
  1835. Lisp_Object Qheight;
  1836. Lisp_Object Qminibuffer;
  1837. Lisp_Object Qmodeline;
  1838. Lisp_Object Qname;
  1839. Lisp_Object Qunsplittable;
  1840. Lisp_Object Qmenu_bar_lines;
  1841. Lisp_Object Qwidth;
  1842.  
  1843. Lisp_Object Vterminal_frame;
  1844. #ifdef AMIGA
  1845. Lisp_Object Vdefault_frame_alist;
  1846. #endif
  1847.  
  1848. /* Unless this function is defined, providing set-frame-height and
  1849.    set-frame-width doesn't help compatibility any, since they both
  1850.    want this as their first argument.  */
  1851. DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
  1852.   /* Don't confuse make-docfile by having two doc strings for this function.
  1853.      make-docfile does not pay attention to #if, for good reason!  */
  1854.   0)
  1855.   ()
  1856. {
  1857.   Lisp_Object tem;
  1858.   XFASTINT (tem) = 0;
  1859.   return tem;
  1860. }
  1861. DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
  1862.   /* Don't confuse make-docfile by having two doc strings for this function.
  1863.      make-docfile does not pay attention to #if, for good reason!  */
  1864.   0)
  1865.   (object)
  1866.      Lisp_Object object;
  1867. {
  1868.   return Qnil;
  1869. }
  1870.  
  1871. DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
  1872.   /* Don't confuse make-docfile by having two doc strings for this function.
  1873.      make-docfile does not pay attention to #if, for good reason!  */
  1874.   0)
  1875.   (frame, rows, pretend)
  1876.      Lisp_Object frame, rows, pretend;
  1877. {
  1878.   CHECK_NUMBER (rows, 0);
  1879.  
  1880.   change_frame_size (0, XINT (rows), 0, !NILP (pretend), 0);
  1881.   return Qnil;
  1882. }
  1883.  
  1884. DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
  1885.   /* Don't confuse make-docfile by having two doc strings for this function.
  1886.      make-docfile does not pay attention to #if, for good reason!  */
  1887.   0)
  1888.   (frame, cols, pretend)
  1889.      Lisp_Object frame, cols, pretend;
  1890. {
  1891.   CHECK_NUMBER (cols, 0);
  1892.  
  1893.   change_frame_size (0, 0, XINT (cols), !NILP (pretend), 0);
  1894.   return Qnil;
  1895. }
  1896.  
  1897. DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
  1898.   /* Don't confuse make-docfile by having two doc strings for this function.
  1899.      make-docfile does not pay attention to #if, for good reason!  */
  1900.   0)
  1901.   (frame, cols, rows)
  1902.      Lisp_Object frame, cols, rows;
  1903. {
  1904.   CHECK_NUMBER (cols, 2);
  1905.   CHECK_NUMBER (rows, 1);
  1906.  
  1907.   change_frame_size (0, XINT (rows), XINT (cols), 0, 0);
  1908.  
  1909.   return Qnil;
  1910. }
  1911.  
  1912. DEFUN ("frame-height", Fframe_height, Sframe_height, 0, 1, 0,
  1913.   "Return number of lines available for display on FRAME.\n\
  1914. If FRAME is omitted, describe the currently selected frame.")
  1915.   (frame)
  1916.     Lisp_Object frame;
  1917. {
  1918.   return make_number (FRAME_HEIGHT (selected_frame));
  1919. }
  1920.  
  1921. DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 1, 0,
  1922.   "Return number of columns available for display on FRAME.\n\
  1923. If FRAME is omitted, describe the currently selected frame.")
  1924.   (frame)
  1925.     Lisp_Object frame;
  1926. {
  1927.   return make_number (FRAME_WIDTH (selected_frame));
  1928. }
  1929.  
  1930. DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
  1931.   0, 1, 0,
  1932.   /* Don't confuse make-docfile by having two doc strings for this function.
  1933.      make-docfile does not pay attention to #if, for good reason!  */
  1934.   0)
  1935.   (frame)
  1936.      Lisp_Object frame;
  1937. {
  1938.   return make_number (1);
  1939. }
  1940.  
  1941.  
  1942. DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
  1943.   0, 1, 0,
  1944.   /* Don't confuse make-docfile by having two doc strings for this function.
  1945.      make-docfile does not pay attention to #if, for good reason!  */
  1946.   0)
  1947.   (frame)
  1948.      Lisp_Object frame;
  1949. {
  1950.   return make_number (1);
  1951. }
  1952.  
  1953. DEFUN ("frame-pixel-height", Fframe_pixel_height, 
  1954.        Sframe_pixel_height, 0, 1, 0,
  1955.   /* Don't confuse make-docfile by having two doc strings for this function.
  1956.      make-docfile does not pay attention to #if, for good reason!  */
  1957.   0)
  1958.   (frame)
  1959.      Lisp_Object frame;
  1960. {
  1961.   return make_number (FRAME_HEIGHT (f));
  1962. }
  1963.  
  1964. DEFUN ("frame-pixel-width", Fframe_pixel_width, 
  1965.        Sframe_pixel_width, 0, 1, 0,
  1966.   /* Don't confuse make-docfile by having two doc strings for this function.
  1967.      make-docfile does not pay attention to #if, for good reason!  */
  1968.   0)
  1969.   (frame)
  1970.      Lisp_Object frame;
  1971. {
  1972.   return make_number (FRAME_WIDTH (f));
  1973. }
  1974.  
  1975. /* These are for backward compatibility with Emacs 18.  */
  1976.  
  1977. DEFUN ("set-screen-height", Fset_screen_height, Sset_screen_height, 1, 2, 0,
  1978.   "Tell redisplay that the screen has LINES lines.\n\
  1979. Optional second arg non-nil means that redisplay should use LINES lines\n\
  1980. but that the idea of the actual height of the screen should not be changed.")
  1981.   (lines, pretend)
  1982.      Lisp_Object lines, pretend;
  1983. {
  1984.   CHECK_NUMBER (lines, 0);
  1985.  
  1986.   change_frame_size (0, XINT (lines), 0, !NILP (pretend), 0);
  1987.   return Qnil;
  1988. }
  1989.  
  1990. DEFUN ("set-screen-width", Fset_screen_width, Sset_screen_width, 1, 2, 0,
  1991.   "Tell redisplay that the screen has COLS columns.\n\
  1992. Optional second arg non-nil means that redisplay should use COLS columns\n\
  1993. but that the idea of the actual width of the screen should not be changed.")
  1994.   (cols, pretend)
  1995.      Lisp_Object cols, pretend;
  1996. {
  1997.   CHECK_NUMBER (cols, 0);
  1998.  
  1999.   change_frame_size (0, 0, XINT (cols), !NILP (pretend), 0);
  2000.   return Qnil;
  2001. }
  2002.  
  2003. DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
  2004.   /* Don't confuse make-docfile by having two doc strings for this function.
  2005.      make-docfile does not pay attention to #if, for good reason!  */
  2006.   0)
  2007.   ()
  2008. #ifndef HAVE_MOUSE
  2009. {
  2010.   return Fcons (Qnil, Fcons (Qnil, Qnil));
  2011. }
  2012. #else
  2013. {
  2014.   FRAME_PTR f;
  2015.   Lisp_Object lispy_dummy;
  2016.   enum scroll_bar_part party_dummy;
  2017.   Lisp_Object x, y;
  2018.   int col, row;
  2019.   unsigned long long_dummy;
  2020.  
  2021.   f = selected_frame;
  2022.   x = y = Qnil;
  2023.  
  2024.   /* It's okay for the hook to refrain from storing anything.  */
  2025.   if (mouse_position_hook)
  2026.     (*mouse_position_hook) (&f,
  2027.                 &lispy_dummy, &party_dummy,
  2028.                 &x, &y,
  2029.                 &long_dummy);
  2030.   if (! NILP (x))
  2031.     {
  2032.       col = XINT (x);
  2033.       row = XINT (y);
  2034.       pixel_to_glyph_coords (f, col, row, &col, &row, 0, 1);
  2035.       XSETINT (x, col);
  2036.       XSETINT (y, row);
  2037.     }
  2038.   lispy_dummy = Qnil;
  2039.   return Fcons (lispy_dummy, Fcons (x, y));
  2040. }
  2041.  
  2042. DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
  2043.        Smouse_pixel_position, 0, 0, 0,
  2044.   "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
  2045. The position is given in pixel units, where (0, 0) is the\n\
  2046. upper-left corner.\n\
  2047. If Emacs is running on a mouseless terminal or hasn't been programmed\n\
  2048. to read the mouse position, it returns the selected frame for FRAME\n\
  2049. and nil for X and Y.")
  2050.   ()
  2051. {
  2052.   FRAME_PTR f;
  2053.   Lisp_Object lispy_dummy;
  2054.   enum scroll_bar_part party_dummy;
  2055.   Lisp_Object x, y;
  2056.   int col, row;
  2057.   unsigned long long_dummy;
  2058.  
  2059.   f = selected_frame;
  2060.   x = y = Qnil;
  2061.  
  2062.   /* It's okay for the hook to refrain from storing anything.  */
  2063.   if (mouse_position_hook)
  2064.     (*mouse_position_hook) (&f,
  2065.                 &lispy_dummy, &party_dummy,
  2066.                 &x, &y,
  2067.                 &long_dummy);
  2068.   lispy_dummy = Qnil;
  2069.   return Fcons (lispy_dummy, Fcons (x, y));
  2070. }
  2071. #endif /* HAVE_MOUSE */
  2072.  
  2073.  
  2074. #ifndef AMIGA
  2075. void
  2076. store_in_alist (alistptr, prop, val)
  2077.      Lisp_Object *alistptr, val;
  2078.      Lisp_Object prop;
  2079. {
  2080.   register Lisp_Object tem;
  2081.  
  2082.   tem = Fassq (prop, *alistptr);
  2083.   if (EQ (tem, Qnil))
  2084.     *alistptr = Fcons (Fcons (prop, val), *alistptr);
  2085.   else
  2086.     Fsetcdr (tem, val);
  2087. }
  2088. #endif
  2089.  
  2090. #ifndef AMIGA
  2091. DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
  2092.   /* Don't confuse make-docfile by having two doc strings for this function.
  2093.      make-docfile does not pay attention to #if, for good reason!  */
  2094.   0)
  2095.   (frame)
  2096.      Lisp_Object frame;
  2097. {
  2098.   Lisp_Object alist;
  2099.   FRAME_PTR f;
  2100.  
  2101.   if (EQ (frame, Qnil))
  2102.     f = selected_frame;
  2103.   else
  2104.     {
  2105.       CHECK_FRAME (frame, 0);
  2106.       f = XFRAME (frame);
  2107.     }
  2108.  
  2109.   if (!FRAME_LIVE_P (f))
  2110.     return Qnil;
  2111.  
  2112.   alist = Qnil;
  2113.   store_in_alist (&alist, Qname, build_string ("emacs"));
  2114.   store_in_alist (&alist, Qheight, make_number (FRAME_HEIGHT (f)));
  2115.   store_in_alist (&alist, Qwidth, make_number (FRAME_WIDTH (f)));
  2116.   store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil));
  2117.   store_in_alist (&alist, Qminibuffer, FRAME_MINIBUF_WINDOW (f));
  2118.   store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
  2119.   store_in_alist (&alist, Qmenu_bar_lines, (FRAME_MENU_BAR_LINES (f)));
  2120.  
  2121.   return alist;
  2122. }
  2123. #endif
  2124.  
  2125. #ifndef AMIGA
  2126. DEFUN ("modify-frame-parameters", Fmodify_frame_parameters, 
  2127.        Smodify_frame_parameters, 2, 2, 0,
  2128.   /* Don't confuse make-docfile by having two doc strings for this function.
  2129.      make-docfile does not pay attention to #if, for good reason!  */
  2130.   0)
  2131.   (frame, alist)
  2132.      Lisp_Object frame, alist;
  2133. {
  2134.   return Qnil;
  2135. }
  2136. #endif
  2137.  
  2138. DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
  2139.   /* Don't confuse make-docfile by having two doc strings for this function.
  2140.      make-docfile does not pay attention to #if, for good reason!  */
  2141.   0)
  2142.   (frame)
  2143.      Lisp_Object frame;
  2144. {
  2145.   return Qt;
  2146. }
  2147.  
  2148. syms_of_frame ()
  2149. {
  2150.   Qheight = intern ("height");
  2151.   staticpro (&Qheight);
  2152.   Qminibuffer = intern ("minibuffer");
  2153.   staticpro (&Qminibuffer);
  2154.   Qmodeline = intern ("modeline");
  2155.   staticpro (&Qmodeline);
  2156.   Qname = intern ("name");
  2157.   staticpro (&Qname);
  2158.   Qunsplittable = intern ("unsplittable");
  2159.   staticpro (&Qunsplittable);
  2160.   Qmenu_bar_lines = intern ("menu-bar-lines");
  2161.   staticpro (&Qmenu_bar_lines);
  2162.   Qwidth = intern ("width");
  2163.   staticpro (&Qwidth);
  2164.  
  2165.   DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
  2166.     "The initial frame-object, which represents Emacs's stdout.");
  2167.   XFASTINT (Vterminal_frame) = 0;
  2168.  
  2169. #ifdef AMIGA
  2170.   DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
  2171.     "Alist of default values for frame creation.\n\
  2172. These may be set in your init file, like this:\n\
  2173.   (setq default-frame-alist '((width . 80) (height . 55)))\n\
  2174. These override values given in window system configuration data, like\n\
  2175. X Windows' defaults database.\n\
  2176. For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
  2177. For values specific to the separate minibuffer frame, see\n\
  2178. `minibuffer-frame-alist'.");
  2179.   Vdefault_frame_alist = Qnil;
  2180. #endif /* AMIGA */
  2181.  
  2182. #ifdef USE_EXTERNAL_MENU_BAR
  2183.   the_only_param_alist = Qnil;
  2184.   staticpro(&the_only_param_alist);
  2185.   the_only_menu_bar_items = Qnil;
  2186.   staticpro(&the_only_menu_bar_items);
  2187.   the_only_menu_bar_vector = Qnil;
  2188.   staticpro(&the_only_menu_bar_vector);
  2189. #endif /* USE_EXTERNAL_MENU_BAR */
  2190. #ifdef USE_SCROLL_BARS
  2191.   the_only_scroll_bars = Qnil;
  2192.   staticpro(&the_only_scroll_bars);
  2193.   the_only_condemned_scroll_bars = Qnil;
  2194.   staticpro(&the_only_condemned_scroll_bars);
  2195. #endif /* USE_SCROLL_BARS */
  2196.  
  2197.   defsubr (&Sselected_frame);
  2198.   defsubr (&Sframep);
  2199.   defsubr (&Sframe_char_height);
  2200.   defsubr (&Sframe_char_width);
  2201.   defsubr (&Sframe_pixel_height);
  2202.   defsubr (&Sframe_pixel_width);
  2203.   defsubr (&Sset_frame_height);
  2204.   defsubr (&Sset_frame_width);
  2205.   defsubr (&Sset_frame_size);
  2206.   defsubr (&Sset_screen_height);
  2207.   defsubr (&Sset_screen_width);
  2208.   defsubr (&Sframe_height);
  2209.   Ffset (intern ("screen-height"), intern ("frame-height"));
  2210.   defsubr (&Sframe_width);
  2211.   Ffset (intern ("screen-width"), intern ("frame-width"));
  2212.   defsubr (&Smouse_position);
  2213. #ifdef AMIGA
  2214.   defsubr (&Smouse_pixel_position);
  2215.   defsubr (&Smake_frame_visible);
  2216. #if 0
  2217.   defsubr (&Smake_frame_invisible);
  2218. #endif
  2219.   defsubr (&Sraise_frame);
  2220.   defsubr (&Slower_frame);
  2221. #endif
  2222.   defsubr (&Sframe_parameters);
  2223.   defsubr (&Smodify_frame_parameters);
  2224.   defsubr (&Sframe_live_p);
  2225. }
  2226.  
  2227. keys_of_frame ()
  2228. {
  2229. }
  2230.  
  2231. #endif /* not MULTI_FRAME */
  2232.